Bit Arrays
Compressed boolean arrays are useful to create memory efficient masks, so they are part of divERGe as static inline functions (i.e. only from the C interface). Documentation of all functions is found below:
-
static inline size_t bitary_nwords(size_t nbit)
[source] get number of bytes required to represent
nbitcontiguous bits in memory
-
static inline cbytes_t *bitary_alloc(size_t nbit)
[source] allocate a bit array with at least
nbitbits, all set to zero. The returnet memory must be free’d withfreeordiverge_mem_free().
-
static inline void bitary_set(cbytes_t *ary, size_t bitidx)
[source] set the \(n\)-th bit (
bitidx) of the bit arrayaryto one
-
static inline void bitary_unset(cbytes_t *ary, size_t bitidx)
[source] set the \(n\)-th bit (
bitidx) of the bit arrayaryto zero
-
static inline void bitary_toggle(cbytes_t *ary, size_t bitidx)
[source] toggle the \(n\)-th bit (
bitidx) of the bit arrayary
-
static inline cbit bitary_get(const cbytes_t *ary, size_t bitidx)
[source] get the \(n\)-th bit (
bitidx) of the bit arrayary
-
static inline void bitary_set_all(cbytes_t *ary, size_t nbit)
[source] set the first
nbitbits of the bit arrayaryto one
-
static inline void bitary_unset_all(cbytes_t *ary, size_t nbit)
[source] set the first
nbitbits of the bit arrayaryto zero
-
static inline void bitary_toggle_all(cbytes_t *ary, size_t nbit)
[source] toggle the first
nbitbits of the bit arrayary
-
static inline size_t bitary_count(cbytes_t *ary, size_t nbit)
[source] count the number of nonzero bits in ary, using fast __builtin_popcountll if available
-
static inline size_t bitary_count_parallel(cbytes_t *ary, size_t nbit, int nthr)
[source] same as
bitary_count()but with omp parallelizationnthr-threaded